package com.example.redis_demo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.data.annotation.Id;
import org.springframework.data.redis.core.RedisHash;
import org.springframework.data.redis.core.index.Indexed;

import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
@RedisHash("persons")
@ToString
public class Person {
    @javax.persistence.Id
    @Id  //主键
    private Long id;
    //生成二级索引，方便查询
    @Indexed
    private String firstName; //名
    @Indexed
    private String lastName; //姓
    private Address address; //地址
    private List<Family> familyList; //家庭成员

    private Family family;
    //构造函数可选
    public Person(Long id, String firstName, String lastName, Address address, List<Family> familyList1) {
        this.id = id;
        this.firstName = firstName;
        this.lastName = lastName;
        this.address = address;
    }
    public Person(Long id, String firstName, String lastName, List familyList) {
        this.id = id;
        this.firstName = firstName;
        this.lastName = lastName;
        this.familyList = familyList;
    }




}
